
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<link rel=stylesheet href='include/hoj.css' type='text/css'>
</head>
<body>
<center>
<div style="width:90%; text-align:left">
<img src="image/logo.png"/>
</div>
<table width=96%> 
	<tr align="center" class='hd' valign="top">
				<th><a href="faqs.php">F.A.Qs</a></th>
		<th><a href="./bbs.php">Web Board</a></th>
		<th><a href="./">Home</a></th>
		<th><a href="./problemset.html">ProblemSet</a></th>
		<th><a href="./status.php">Status</a></th>
		<th><a href="./ranklist.php">Ranklist</a></th>
		<th><a href="./contest.php">Contest</a></th>
		<th><a href=loginpage.php>Login</a></th><th><a href=registerpage.php>Register</a></th>	</tr>
</table>
</center>
<center>
<div class="notice">
	<div>
		<B>Notice:</B>鉴于种种原因，本OJ自下周星期一（3月5号）开始不再全面开放，请各位做好善后事宜，谢谢合作。	</div>
</div>
</center>
</div>
<title>Problem 2334. -- [SCOI2011]镜像拆分 -- 衡阳八中OJ离线版-2012-02-29</title><center><h2>2334: [SCOI2011]镜像拆分</h2><span class=green>Time Limit: </span>10 Sec&nbsp;&nbsp;<span class=green>Memory Limit: </span>128 MB<br><span class=green>Submit: </span>7&nbsp;&nbsp;<span class=green>Solved: </span>5<br>[<a href='submitpage.php?id=2334'>Submit</a>][<a href='problemstatus.php?id=2334'>Status</a>][<a href='bbs.php?id=2334'>Discuss</a>]</center><h2>Description</h2><div class=content><p class="p0" style="margin-top: 0pt; margin-bottom: 0pt"><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-indent: 21pt"><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">lxhgww<font face="宋体">非常喜欢数字游戏，他发现，很多数都可以表示成两个相互反转的数之和，他把这个现象称为数的</font><font face="Times New Roman">&ldquo;</font><font face="宋体">镜像拆分</font><font face="Times New Roman">&rdquo;</font><font face="宋体">。比如</font><font face="Times New Roman">66</font><font face="宋体">共有五种镜像拆分方法：</font></span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-indent: 21pt; text-align: center"><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">66&nbsp;=&nbsp;15&nbsp;+&nbsp;51</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-indent: 21pt; text-align: center"><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">66&nbsp;=&nbsp;24&nbsp;+&nbsp;42</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-indent: 21pt; text-align: center"><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">66&nbsp;=&nbsp;33&nbsp;+&nbsp;33</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-indent: 21pt; text-align: center"><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">66&nbsp;=&nbsp;42&nbsp;+&nbsp;24</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-indent: 21pt; text-align: center"><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">66&nbsp;=&nbsp;51&nbsp;+&nbsp;15</span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-indent: 21pt"><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">注意，前导<font face="Times New Roman">0</font><font face="宋体">是不允许的，所以</font><font face="Times New Roman">66&nbsp;=&nbsp;60&nbsp;+&nbsp;06</font><font face="宋体">不算做合法的镜像拆分。</font></span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-indent: 21pt"><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">现在<font face="Times New Roman">lxhgww</font><font face="宋体">想知道，在</font><font face="Times New Roman">K</font><font face="宋体">进制下，对于在</font><font face="Times New Roman">[A,&nbsp;B]</font><font face="宋体">区间内的数，其镜像拆分的方案数之和是多少？</font></span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-indent: 21pt"><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<!--EndFragment--></div><h2>Input</h2><div class=content><p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-indent: 21pt"><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">输入的第一行是一个数<font face="Times New Roman">K</font><font face="宋体">。</font></span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-indent: 21pt"><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">输入的第二行是一个数<font face="Times New Roman">n</font><font face="宋体">，表示数字</font><font face="Times New Roman">A</font><font face="宋体">的长度。</font></span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-indent: 21pt"><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">接下来<font face="Times New Roman">n</font><font face="宋体">行，表示</font><font face="Times New Roman">A</font><font face="宋体">从低位开始的每一位数字。</font></span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-indent: 21pt"><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">然后是一个数<font face="Times New Roman">m</font><font face="宋体">，表示数字</font><font face="Times New Roman">B</font><font face="宋体">的长度。</font></span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-indent: 21pt"><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">接下来<font face="Times New Roman">m</font><font face="宋体">行，表示</font><font face="Times New Roman">B</font><font face="宋体">从低位开始的每一位数字。</font></span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-indent: 21pt"><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p></div><h2>Output</h2><div class=content><p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-indent: 21pt"><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'">输出一行，包含一个整数，表示镜像拆分的方案数之和。由于这个答案非常大，只需要输出这个答案除以<font face="Times New Roman">20110521</font><font face="宋体">的余数。</font></span><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p>
<p class="p0" style="margin-top: 0pt; margin-bottom: 0pt; text-indent: 21pt"><span style="font-size: 10.5pt; font-family: 'Times New Roman'; mso-spacerun: 'yes'"><o:p></o:p></span></p></div><h2>Sample Input</h2>
			<div class=content><span class=sampledata>10<br />
<br />
2<br />
<br />
6<br />
<br />
6<br />
<br />
2<br />
<br />
6<br />
<br />
6<br />
<br />
</span></div><h2>Sample Output</h2>
			<div class=content><span class=sampledata><br />
5<br />
</span></div><h2>HINT</h2>
			<div class=content><p><p>【数据范围】</p><br />
<p>对于20%的数据，保证： 2&lt;=K&lt;=100，1&lt;=n, m&lt;=100</p><br />
<p>对于50%的数据，保证：2&lt;=K&lt;=1000，1&lt;=n, m&lt;=1000</p><br />
<p>对于100%的数据，保证： 2&lt;=K&lt;=100000，1&lt;=n, m&lt;=100000</p><br />
<p>对于所有的数据，保证： 0&lt;A&lt;=B，A, B的每一位数字都在[0, K-1]的范围内，没有前导0<br /><br />
</p></p></div><h2>Source</h2>
			<div class=content><p><a href='problemset.html?search=Day2'>Day2</a></p></div><center>[<a href='submitpage.php?id=2334'>Submit</a>][<a href='problemstatus.php?id=2334'>Status</a>][<a href='bbs.php?id=2334'>Discuss</a>]</center>﻿<br>

<a href="./"><span class=red>HOME</span></a>
<a href="javascript:history.go(-1)"><span class=red>Back</span></a>

<hr>
<center>
	<div class="footer">
			<a href=setlang.php?lang=ko>한국어</a>&nbsp;
		<a href=setlang.php?lang=cn>中文</a>&nbsp;
		<a href=setlang.php?lang=fa>فارسی</a>&nbsp;
		<a href=setlang.php?lang=en>English</a>&nbsp;
		<a href=setlang.php?lang=th>ไทย</a>
	<br>		<div>版权所有 &copy;2008-2012 WaterPark Organization. | <script src="http://s21.cnzz.com/stat.php?id=2982771&web_id=2982771" language="JavaScript"></script>
</div>
		<div>Based on opensource project <a href="http://hustoj.googlecode.com">hustoj</a>.</div>
	</div>
</center>
</body>
</html>
